<?php

class SQL
{

    private static $instance;
    private $type = "mysql";
    private $host = "localhost";
    private $dbname = "gestion_stage";
    private $username = "root";
    private $password = '';
    private $dbh;

    private function __construct()
    {
        try
        {
            $this->dbh = new PDO($this->type . ':host=' . $this->host . '; dbname=' . $this->dbname, $this->username, $this->password);
        }
        catch (PDOException $e)
        {
            echo "<div class='error'>Erreur !: " . $e->getMessage() . "</div>";
            die();
        }
    }

    public static function getInstance()
    {
        if (!self::$instance instanceof self)
        {
            self::$instance = new self;
        }
        return self::$instance;
    }

    public function getConnection()
    {
        return $this->dbh;
    }

}

?>